cmake_minimum_required(VERSION 3.10)
set(CMAKE_BUILD_TYPE Debug)
project(mongoose_cjson_example)

# Set the target architecture
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR mipsel)
set(CMAKE_CROSSCOMPILING 1)

# Set the path to the cross-compiler toolchain
set(CMAKE_C_COMPILER /opt/openwrt-sdk-22.03.2-ramips-mt7620_gcc-11.2.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/bin/mipsel-openwrt-linux-gcc)
set(CMAKE_CXX_COMPILER /opt/openwrt-sdk-22.03.2-ramips-mt7620_gcc-11.2.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/bin/mipsel-openwrt-linux-g++)


# 添加cJSON库的源代码
add_library(cjson STATIC cJSON.c)

# 添加头文件搜索路径，以便找到cJSON.h
include_directories(.)

# 添加Mongoose代码，使用mg.c、mongoose.c和json.c三个源文件
add_executable(mongoose_cjson_example mongoose.c cJSON.c  main.c)

# 链接需要的库
target_link_libraries(mongoose_cjson_example pthread)

# 添加编译选项
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
